package com.ruoyi.edge.application.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.mybatis.core.page.PageQuery;
import com.ruoyi.common.mybatis.core.page.TableDataInfo;
import com.ruoyi.edge.application.domain.SourceProject;
import com.ruoyi.edge.application.service.SourceProjectService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 源代码项目管理
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/sourceProject")
public class SourceProjectController extends BaseController {

    private final SourceProjectService sourceProjectService;

    /**
     * 获取列表
     */
    @SaCheckPermission("edge:sourceProject:listPage")
    @GetMapping("/listPage")
    public TableDataInfo<SourceProject> listPage(SourceProject sourceProject, PageQuery pageQuery) {
        return sourceProjectService.listPage(sourceProject, pageQuery);
    }

    /**
     * 获取详情
     */
    @SaCheckPermission("edge:sourceProject:get")
    @GetMapping("/get")
    public R<SourceProject> get(String id) {
        return sourceProjectService.get(id);
    }

    /**
     * 新增
     */
    @SaCheckPermission("edge:sourceProject:add")
    @PostMapping("add")
    public R<String> add(@RequestBody SourceProject sourceProject) {
        return sourceProjectService.add(sourceProject);
    }

    /**
     * 编辑
     */
    @SaCheckPermission("edge:sourceProject:edit")
    @PutMapping("edit")
    public R<String> edit(@RequestBody SourceProject sourceProject) {
        return sourceProjectService.edit(sourceProject);
    }

    /**
     * 删除
     */
    @SaCheckPermission("edge:sourceProject:remove")
    @DeleteMapping("remove")
    public R<String> remove(String id) {
        return sourceProjectService.remove(id);
    }

}
